package com.example.service;

import com.example.entity.Payment;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

@Service
public class PaymentService {
    private final Map<Long, Payment> paymentMap = new ConcurrentHashMap<>();
    private final AtomicLong idGenerator = new AtomicLong();

    public Payment create(Payment payment) {
        payment.setId(idGenerator.incrementAndGet());
        paymentMap.put(payment.getId(), payment);
        return payment;
    }

    public Payment getPaymentById(Long id) {
        return paymentMap.get(id);
    }
} 